﻿using Exercises2.Model.math;
using Xunit;

namespace UnitTests.Model.math {
    public class ComplexTest {
        private Complex c1;
        private Complex c2;

        [Fact]
        public void Addtest2() {
            c1 = new Complex(6, 3);
            c2 = new Complex(3, 2);
            Complex expected = new Complex(9, 5);
            Complex actual = c1.Add(c2);
            Assert.Equal(expected, actual);
        }

        [Fact]
        public void SubtractTest() {
            c1 = new Complex(6, 3);
            c2 = new Complex(3, 2);
            Complex expected = new Complex(3, 1);
            Complex actual = c1.Subtract(c2);
            Assert.Equal(expected, actual);
        }

        [Fact]
        public void MultiplyTest() {
            c1 = new Complex(3, 2);
            c2 = new Complex(5, 3);
            Complex expected = new Complex(9, 19);
            Complex actual = c1.Multiply(c2);
            Assert.Equal(expected, actual);
        }

        [Fact]
        public void DivideTest() {
            c1 = new Complex(3, 2);
            c2 = new Complex(5, 3);
            double real = (21F/34F);
            double imag = (1F/34F);
            Complex expected = new Complex(real, imag);
            Complex actual = c1.Divide(c2);
            Assert.Equal(expected, actual);
        }


        [Fact]
        public void ConjTest() {
            c1 = new Complex(3, 2);
            Complex expected = new Complex(3, -2);
            Complex actual = c1.Conj();
            Assert.Equal(expected, actual);
        }

        [Fact]
        public void IsEqualsTest() {
            c1 = new Complex(3, 3);
            c2 = new Complex(3, 3);
            bool actual = c1.Equals(c2);
            Assert.Equal(true, actual);

            c2 = new Complex(3, 6);
            actual = c1.Equals(c2);
            Assert.Equal(false, actual);
        }
    }
}